package org.javia.arity;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TokenTest {

	Token tok;
	@Before
	public void setUp() throws Exception {
		tok= new Token(1, 2, 3, 4);
	}

	@After
	public void tearDown() throws Exception {
	}

	

	@Test
	public void testToken() {
		tok= new Token(1, 2, 3, 4);
		tok= new Token(11, 5, 6, 7);
		assertEquals(3,tok.setPos(3).position);
		assertEquals(2,tok.setValue(2).value,0.000001);
		assertEquals("qwerty",tok.setAlpha("qwerty").name);
	}

	@Test
	public void testIsDerivative() {
		tok.setAlpha(null);
		assertFalse(tok.isDerivative());
		tok.setAlpha("");
		assertFalse(tok.isDerivative());
		tok.setAlpha("what is this\'");
		assertTrue(tok.isDerivative());
	}

	@Test
	public void testToString() {
		tok= new Token(9,9,9,9);
		assertEquals("0.0",tok.toString());
		tok= new Token(10,9,9,9);
		assertEquals(null,tok.toString());
		tok.setAlpha("what is this\'");
		assertEquals("what is this\'",tok.toString());
		tok= new Token(11,9,9,9);
		assertEquals("null(1)",tok.toString());
		tok.setAlpha("what is this\'");
		assertEquals("what is this\'(1)",tok.toString());
		tok= new Token(2,2,2,2);
		assertEquals("2",tok.toString());

	}

}
